<!DOCTYPE html>
<html>

  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<meta http-equiv="Cache-Control" content="no-siteapp" />

    <title>TBOOX开源工程</title>
    <meta name="description" content="专注于跨平台c开发解决方案">

    
    <meta name="keywords" content="tbox,xmake,gbox,c,lua,跨平台,构建工具,编译工具,makefile,make,编译器,图形库,linux,编程,开发" /> 

    <!-- qq oauth -->
    <meta property="qc:admins" content="5211601217706727767255" />

    <!--icon -->
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
    <link rel="icon" sizes="192x192" href="/static/img/nice-highres.png" />
	<link rel="apple-touch-icon-precomposed" href="/static/img/apple-touch-icon-57x57-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/static/img/apple-touch-icon-72x72-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/static/img/apple-touch-icon-114x114-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/static/img/apple-touch-icon-144x144-precomposed.png" />
	<link rel="apple-touch-icon-precomposed" sizes="180x180" href="/static/img/retinahd_icon.png" />
	<meta name="msapplication-TileImage" content="/static/img/retinahd_icon.png" />
	
    <link rel="stylesheet" href=" /css/fontawesome/css/font-awesome.min.css ">
    <link rel="stylesheet" href=" /css/main.css ">
    <link rel="canonical" href="https://tboox.org/cn/page36/">
    <link rel="alternate" type="application/rss+xml" title="TBOOX Open Source Project" href="https://tboox.org/feed.xml ">
    <link rel="alternate" hreflang="en" href="https://tboox.org/" />
    <link rel="alternate" hreflang="zh-Hans" href="https://tboox.org/cn/" />

    <!-- css -->
    <link href="/css/reward.css" rel="stylesheet" type="text/css"> 




    <script type="text/javascript">
    function isPC(){    
        var userAgentInfo = navigator.userAgent;  
        var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");    
        var flag = true;    
        for (var v = 0; v < Agents.length; v++) {    
            if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }    
        }    
        return flag;    
    }
    </script>

<!-- baidu ads -->



    <!-- baidu ads -->

</head>


  <body>

    <header id="top">
    <div class="wrapper">
        <a href="/cn" class="brand">TBOOX</a>
        <button id="headerMenu" class="menu"><i class="fa fa-bars"></i></button>
        <nav id="headerNav">
            <ul>
                <li>
                    
                    <a href="/?lang=0">
                    
                        <i class="fa fa-home"></i>English
                    </a>
                </li>

                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/project/">
                            
                        
                            <i class="fa fa-bookmark"></i>项目
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/archive/">
                            
                        
                            <i class="fa fa-archive"></i>归档
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/category/">
                            
                        
                            <i class="fa fa-th-list"></i>分类
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/tag/">
                            
                        
                            <i class="fa fa-tags"></i>标记
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/docs/">
                            
                        
                            <i class="fa fa-book"></i>文档
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="https://xmake.io/#/zh-cn/about/contact" target="_blank" >
                            
                        
                            <i class="fa fa-forumbee"></i>社区
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/donation/">
                            
                        
                            <i class="fa fa-heart"></i>捐助
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                    
                    <li>
                        
                            
                            <a href="/cn/about/">
                            
                        
                            <i class="fa fa-user"></i>关于
                        </a>
                    </li>
                    
                    
                
                    
                    
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                    
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
                    
                
            </ul>
        </nav>
    </div>
</header>



        <div class="page clearfix" index="">
    <div class="left">
        <h1>TBOOX开源工程</h1>
        <small>专注于跨平台c开发解决方案</small>
        <hr />

        <ul>
            
              <li>
                <h2>
                  <a class="post-link" href="/cn/2016/06/09/custom-action/">高级特性之自定义脚本使用</a>
                </h2>
                <div class="label">
                    <div class="label-card">
                        <i class="fa fa-calendar"></i>2016-06-09
                    </div>
                    <div class="label-card">
                        
                    </div>
                    <div class="label-card">
                        
                    </div>

                    <div class="label-card">
                    


<!-- <span class="point">•</span> -->
<span class="categories">
  <i class="fa fa-th-list"></i>
  
    
        <a href="/category/#xmake" title="Category: xmake" rel="category">xmake</a>
    
  

  <!-- <span class="point">•</span> -->
</span>


                    </div>

                    <div class="label-card">
                    
<!-- <span class="point">•</span> -->
<span class="pageTag">
  <i class="fa fa-tags"></i>
  
    
        <a href="/cn/tag/#xmake" title="Tag: xmake" rel="tag">xmake</a>&nbsp;
    
        <a href="/cn/tag/#自定义脚本" title="Tag: 自定义脚本" rel="tag">自定义脚本</a>&nbsp;
    
        <a href="/cn/tag/#安装" title="Tag: 安装" rel="tag">安装</a>&nbsp;
    
        <a href="/cn/tag/#打包" title="Tag: 打包" rel="tag">打包</a>&nbsp;
    
        <a href="/cn/tag/#android" title="Tag: android" rel="tag">android</a>&nbsp;
    
        <a href="/cn/tag/#apk" title="Tag: apk" rel="tag">apk</a>&nbsp;
    
        <a href="/cn/tag/#jni" title="Tag: jni" rel="tag">jni</a>
    
  

</span>

                    </div>
                </div>
                <div class="excerpt">
                    <p>xmake提供了自定义打包、安装、运行脚本，可以更加灵活的针对个人实际需求来操作xmake</p>

<p>这里用一个例子详细说明下，比如有个需求，我需要自动编译、安装、运行android app工程，并且能够支持jni
可以进行如下操作</p>

<p>首先创建个基于ant的android app工程，目录结构如下：</p>


                </div>
                <div class="read-all">
 
                    
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    

                    <a href="/cn/2016/06/09/custom-action/"><i class="fa fa-newspaper-o"></i>阅读全文</a>
                </div>
                <hr />
              </li>
            
              <li>
                <h2>
                  <a class="post-link" href="/cn/2016/06/09/api-import/">插件开发之import类库</a>
                </h2>
                <div class="label">
                    <div class="label-card">
                        <i class="fa fa-calendar"></i>2016-06-09
                    </div>
                    <div class="label-card">
                        
                    </div>
                    <div class="label-card">
                        
                    </div>

                    <div class="label-card">
                    


<!-- <span class="point">•</span> -->
<span class="categories">
  <i class="fa fa-th-list"></i>
  
    
        <a href="/category/#xmake" title="Category: xmake" rel="category">xmake</a>
    
  

  <!-- <span class="point">•</span> -->
</span>


                    </div>

                    <div class="label-card">
                    
<!-- <span class="point">•</span> -->
<span class="pageTag">
  <i class="fa fa-tags"></i>
  
    
        <a href="/cn/tag/#xmake" title="Tag: xmake" rel="tag">xmake</a>&nbsp;
    
        <a href="/cn/tag/#插件" title="Tag: 插件" rel="tag">插件</a>&nbsp;
    
        <a href="/cn/tag/#import" title="Tag: import" rel="tag">import</a>&nbsp;
    
        <a href="/cn/tag/#类库" title="Tag: 类库" rel="tag">类库</a>&nbsp;
    
        <a href="/cn/tag/#自定义脚本" title="Tag: 自定义脚本" rel="tag">自定义脚本</a>
    
  

</span>

                    </div>
                </div>
                <div class="excerpt">
                    <p>import的主要用于导入xmake的扩展类库以及一些自定义的类库模块，一般用于 自定义脚本(on_build, on_run ..)、插件开发、模板开发、平台扩展、自定义任务task等地方。</p>

<p>导入机制如下：</p>

<ol>
  <li>优先从当前脚本目录下导入</li>
  <li>再从扩展类库中导入</li>
</ol>

<p>导入的语法规则：</p>

<p>基于.的类库路径规则，例如：</p>

<p>导入core核心扩展模块</p>

<div class="language-lua highlighter-rouge"><pre class="highlight"><code>    <span class="n">import</span><span class="p">(</span><span class="s2">"core.base.option"</span><span class="p">)</span>
    <span class="n">import</span><span class="p">(</span><span class="s2">"core.project"</span><span class="p">)</span>
    <span class="n">import</span><span class="p">(</span><span class="s2">"core.project.task"</span><span class="p">)</span>
    <span class="n">import</span><span class="p">(</span><span class="s2">"core"</span><span class="p">)</span>

    <span class="k">function</span> <span class="nf">main</span><span class="p">()</span>
        
        <span class="c1">-- 获取参数选项</span>
        <span class="nb">print</span><span class="p">(</span><span class="n">option</span><span class="p">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"version"</span><span class="p">))</span>

        <span class="c1">-- 运行任务和插件</span>
        <span class="n">task</span><span class="p">.</span><span class="n">run</span><span class="p">(</span><span class="s2">"hello"</span><span class="p">)</span>
        <span class="n">project</span><span class="p">.</span><span class="n">task</span><span class="p">.</span><span class="n">run</span><span class="p">(</span><span class="s2">"hello"</span><span class="p">)</span>
        <span class="n">core</span><span class="p">.</span><span class="n">project</span><span class="p">.</span><span class="n">task</span><span class="p">.</span><span class="n">run</span><span class="p">(</span><span class="s2">"hello"</span><span class="p">)</span>
    <span class="k">end</span>
</code></pre>
</div>


                </div>
                <div class="read-all">
 
                    
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    

                    <a href="/cn/2016/06/09/api-import/"><i class="fa fa-newspaper-o"></i>阅读全文</a>
                </div>
                <hr />
              </li>
            
              <li>
                <h2>
                  <a class="post-link" href="/cn/2016/03/17/stream-custom/">自定义流的实现和使用</a>
                </h2>
                <div class="label">
                    <div class="label-card">
                        <i class="fa fa-calendar"></i>2016-03-17
                    </div>
                    <div class="label-card">
                        
                    </div>
                    <div class="label-card">
                        
                    </div>

                    <div class="label-card">
                    


<!-- <span class="point">•</span> -->
<span class="categories">
  <i class="fa fa-th-list"></i>
  
    
        <a href="/category/#tbox" title="Category: tbox" rel="category">tbox</a>
    
  

  <!-- <span class="point">•</span> -->
</span>


                    </div>

                    <div class="label-card">
                    
<!-- <span class="point">•</span> -->
<span class="pageTag">
  <i class="fa fa-tags"></i>
  
    
        <a href="/cn/tag/#tbox" title="Tag: tbox" rel="tag">tbox</a>&nbsp;
    
        <a href="/cn/tag/#stream" title="Tag: stream" rel="tag">stream</a>&nbsp;
    
        <a href="/cn/tag/#流" title="Tag: 流" rel="tag">流</a>
    
  

</span>

                    </div>
                </div>
                <div class="excerpt">
                    <p>tbox中提供了常用的一些stream模块，例如：data、file、http、sock等，可以通过指定不同的url，使用相同的接口
进行数据流的读写，非常的方便。</p>

<p>例如：</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code>    <span class="c1">// init stream
</span>    <span class="n">tb_stream_ref_t</span> <span class="n">stream</span> <span class="o">=</span> <span class="n">tb_stream_init_from_url</span><span class="p">(</span><span class="s">"http://www.xxx.com/file.txt"</span><span class="p">);</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">stream</span><span class="p">)</span>
    <span class="p">{</span>
        <span class="c1">// open stream
</span>        <span class="k">if</span> <span class="p">(</span><span class="n">tb_stream_open</span><span class="p">(</span><span class="n">stream</span><span class="p">))</span>
        <span class="p">{</span>
            <span class="c1">// read line
</span>            <span class="n">tb_long_t</span> <span class="n">size</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
            <span class="n">tb_char_t</span> <span class="n">line</span><span class="p">[</span><span class="n">TB_STREAM_BLOCK_MAXN</span><span class="p">];</span>
            <span class="k">while</span> <span class="p">((</span><span class="n">size</span> <span class="o">=</span> <span class="n">tb_stream_bread_line</span><span class="p">(</span><span class="n">stream</span><span class="p">,</span> <span class="n">line</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">line</span><span class="p">)))</span> <span class="o">&gt;=</span> <span class="mi">0</span><span class="p">)</span>
            <span class="p">{</span>
                <span class="c1">// trace
</span>                <span class="n">tb_trace_i</span><span class="p">(</span><span class="s">"line: %s"</span><span class="p">,</span> <span class="n">line</span><span class="p">);</span>
            <span class="p">}</span>
        <span class="p">}</span>

        <span class="c1">// exit stream
</span>        <span class="n">tb_stream_exit</span><span class="p">(</span><span class="n">stream</span><span class="p">);</span>
    <span class="p">}</span>
</code></pre>
</div>

<p>这样的好处是，操作io的模块不需要关心实际的数据流协议，只管从stream中读写数据就行了，实现数据和业务逻辑的解耦。。</p>

<p>但是tbox提供的这些内置stream模块，有时候没法完全咱们的实际需求，例如：</p>

<p>我想读取一个实时数据流的缓存队列，这个数据流一段会不停的送入数据进来，另外一段会不停的读取数据，如果数据不够，就会进入等待</p>

<p>这其实是个很有用的功能，我的很多需求都会用到，例如：流媒体的一些实时数据获取和复用等等。。</p>

<p>那如何实现这样一个stream模块，让tbox的stream接口支持呢，我们只要实现一个自定义的流模块就好，实现起来也不复杂</p>

<p>我们先定义个一个stream类型，例如：</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code>    <span class="c1">// 用户自定义流类型：实时流
</span>    <span class="cp">#define TB_STREAM_TYPE_REAL         (TB_STREAM_TYPE_USER + 1)
</span>
    <span class="c1">// 定义一个控制流代码，之后tb_stream_ctrl需要
</span>    <span class="cp">#define TM_STREAM_CTRL_REAL_PUSH    TB_STREAM_CTRL(TM_STREAM_TYPE_REAL, 1)
</span></code></pre>
</div>

<p>定义个自定义流的数据结构，用于维护咱们的私有数据</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code>    <span class="c1">// 实时流类型
</span>    <span class="k">typedef</span> <span class="k">struct</span> <span class="n">__tb_stream_real_t</span>
    <span class="p">{</span>
        <span class="c1">// 这里定义了一个数据块buffer的队列，用于缓存不断送入的数据
</span>        <span class="n">tb_queue_ref_t</span>      <span class="n">buffers</span><span class="p">;</span>

        <span class="c1">// 总的数据大小
</span>        <span class="n">tb_size_t</span>           <span class="n">size</span><span class="p">;</span>

    <span class="p">}</span><span class="n">tb_stream_real_t</span><span class="p">,</span> <span class="o">*</span><span class="n">tb_stream_real_ref_t</span><span class="p">;</span>

    <span class="c1">// 定义一个buffer块类型，用于维护单个数据块
</span>    <span class="k">typedef</span> <span class="k">struct</span> <span class="n">__tm_real_buffer_t</span>
    <span class="p">{</span>
        <span class="c1">// 数据地址
</span>        <span class="n">tb_byte_t</span><span class="o">*</span>          <span class="n">data</span><span class="p">;</span>

        <span class="c1">// 这个buffer总大小
</span>        <span class="n">tb_size_t</span>           <span class="n">size</span><span class="p">;</span>

        <span class="c1">// 在这个buffer中，当前读取到的数据
</span>        <span class="n">tb_size_t</span>           <span class="n">read</span><span class="p">;</span>

    <span class="p">}</span><span class="n">tm_real_buffer_t</span><span class="p">,</span> <span class="o">*</span><span class="n">tm_real_buffer_ref_t</span><span class="p">;</span>
</code></pre>
</div>

<p>创建一个stream实例，注册一些需要的回调接口</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code>    <span class="c1">// 初始化创建个一个实时流
</span>    <span class="n">tb_stream_ref_t</span> <span class="nf">tb_stream_init_real</span><span class="p">()</span>
    <span class="p">{</span>
        <span class="k">return</span> <span class="n">tb_stream_init</span><span class="p">(</span>  <span class="n">TB_STREAM_TYPE_REAL</span>
                            <span class="p">,</span>   <span class="k">sizeof</span><span class="p">(</span><span class="n">tb_stream_real_t</span><span class="p">)</span>
                            <span class="p">,</span>   <span class="mi">0</span>           <span class="c1">// stream缓存大小（file/sock有用），这里禁用了，因为咱们的流不需要缓存读取
</span>                            <span class="p">,</span>   <span class="n">tb_stream_real_open</span>
                            <span class="p">,</span>   <span class="n">tb_stream_real_clos</span>
                            <span class="p">,</span>   <span class="n">tb_stream_real_exit</span>
                            <span class="p">,</span>   <span class="n">tb_stream_real_ctrl</span>
                            <span class="p">,</span>   <span class="n">tb_stream_real_wait</span>
                            <span class="p">,</span>   <span class="n">tb_stream_real_read</span>
                            <span class="p">,</span>   <span class="n">tb_null</span>     <span class="c1">// 写回调，这里不需要
</span>                            <span class="p">,</span>   <span class="n">tb_null</span>     <span class="c1">// seek，我们这里不需要
</span>                            <span class="p">,</span>   <span class="n">tb_null</span>     <span class="c1">// 刷新写数据，不需要
</span>                            <span class="p">,</span>   <span class="n">tb_null</span><span class="p">);</span>   <span class="c1">// kill当前的stream，很少用，一般用于中断内部读写
</span>    <span class="p">}</span>
</code></pre>
</div>

<p>下面就是具体的回调接口实现了</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code>    <span class="c1">// 实现open回调接口，用于打开stream，tb_stream_open会用到
</span>    <span class="k">static</span> <span class="n">tb_bool_t</span> <span class="nf">tb_stream_real_open</span><span class="p">(</span><span class="n">tb_stream_ref_t</span> <span class="n">stream</span><span class="p">)</span>
    <span class="p">{</span>
        <span class="c1">// check
</span>        <span class="n">tb_stream_real_ref_t</span> <span class="n">rstream</span> <span class="o">=</span> <span class="p">(</span><span class="n">tb_stream_real_ref_t</span><span class="p">)</span><span class="n">stream</span><span class="p">;</span>
        <span class="n">tb_assert_and_check_return_val</span><span class="p">(</span><span class="n">rstream</span><span class="p">,</span> <span class="n">tb_false</span><span class="p">);</span>

        <span class="c1">// 初始化一个buffer队列，并注册自动释放接口：tb_real_buffer_exit，之后有说明
</span>        <span class="n">rstream</span><span class="o">-&gt;</span><span class="n">buffers</span> <span class="o">=</span> <span class="n">tb_queue_init</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">tb_element_mem</span><span class="p">(</span><span class="k">sizeof</span><span class="p">(</span><span class="n">tb_real_buffer_t</span><span class="p">),</span> <span class="n">tb_real_buffer_exit</span><span class="p">,</span> <span class="n">tb_null</span><span class="p">));</span>

        <span class="c1">// init size
</span>        <span class="n">rstream</span><span class="o">-&gt;</span><span class="n">size</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>

        <span class="c1">// ok
</span>        <span class="k">return</span> <span class="o">!!</span><span class="n">rstream</span><span class="o">-&gt;</span><span class="n">buffers</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="c1">// 实现close回调接口，用于关闭stream，tb_stream_clos会用到
</span>    <span class="k">static</span> <span class="n">tb_bool_t</span> <span class="nf">tb_stream_real_clos</span><span class="p">(</span><span class="n">tb_stream_ref_t</span> <span class="n">stream</span><span class="p">)</span>
    <span class="p">{</span>
        <span class="c1">// check
</span>        <span class="n">tb_stream_real_ref_t</span> <span class="n">rstream</span> <span class="o">=</span> <span class="p">(</span><span class="n">tb_stream_real_ref_t</span><span class="p">)</span><span class="n">stream</span><span class="p">;</span>
        <span class="n">tb_assert_and_check_return_val</span><span class="p">(</span><span class="n">rstream</span><span class="p">,</span> <span class="n">tb_false</span><span class="p">);</span>
        
        <span class="c1">// exit buffers
</span>        <span class="k">if</span> <span class="p">(</span><span class="n">rstream</span><span class="o">-&gt;</span><span class="n">buffers</span><span class="p">)</span> <span class="n">tb_queue_exit</span><span class="p">(</span><span class="n">rstream</span><span class="o">-&gt;</span><span class="n">buffers</span><span class="p">);</span>
        <span class="n">rstream</span><span class="o">-&gt;</span><span class="n">buffers</span> <span class="o">=</span> <span class="n">tb_null</span><span class="p">;</span>

        <span class="c1">// ok
</span>        <span class="k">return</span> <span class="n">tb_true</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="c1">// 实现exit回调接口，用于销毁stream，tb_stream_exit会用到
</span>    <span class="k">static</span> <span class="n">tb_void_t</span> <span class="nf">tb_stream_real_exit</span><span class="p">(</span><span class="n">tb_stream_ref_t</span> <span class="n">stream</span><span class="p">)</span>
    <span class="p">{</span>
        <span class="c1">// check
</span>        <span class="n">tb_stream_real_ref_t</span> <span class="n">rstream</span> <span class="o">=</span> <span class="p">(</span><span class="n">tb_stream_real_ref_t</span><span class="p">)</span><span class="n">stream</span><span class="p">;</span>
        <span class="n">tb_assert_and_check_return</span><span class="p">(</span><span class="n">rstream</span><span class="p">);</span>
        
        <span class="c1">// exit buffers
</span>        <span class="k">if</span> <span class="p">(</span><span class="n">rstream</span><span class="o">-&gt;</span><span class="n">buffers</span><span class="p">)</span> <span class="n">tb_queue_exit</span><span class="p">(</span><span class="n">rstream</span><span class="o">-&gt;</span><span class="n">buffers</span><span class="p">);</span>
        <span class="n">rstream</span><span class="o">-&gt;</span><span class="n">buffers</span> <span class="o">=</span> <span class="n">tb_null</span><span class="p">;</span>

        <span class="c1">// clear size
</span>        <span class="n">rstream</span><span class="o">-&gt;</span><span class="n">size</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="c1">// 实现read回调接口，用于读取数据，tb_stream_read/tb_stream_bread等接口会用到
</span>    <span class="k">static</span> <span class="n">tb_long_t</span> <span class="nf">tb_stream_real_read</span><span class="p">(</span><span class="n">tb_stream_ref_t</span> <span class="n">stream</span><span class="p">,</span> <span class="n">tb_byte_t</span><span class="o">*</span> <span class="n">data</span><span class="p">,</span> <span class="n">tb_size_t</span> <span class="n">size</span><span class="p">)</span>
    <span class="p">{</span>
        <span class="c1">// check
</span>        <span class="n">tb_stream_real_ref_t</span> <span class="n">rstream</span> <span class="o">=</span> <span class="p">(</span><span class="n">tb_stream_real_ref_t</span><span class="p">)</span><span class="n">stream</span><span class="p">;</span>
        <span class="n">tb_assert_and_check_return_val</span><span class="p">(</span><span class="n">rstream</span> <span class="o">&amp;&amp;</span> <span class="n">rstream</span><span class="o">-&gt;</span><span class="n">buffers</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span>

        <span class="c1">// check
</span>        <span class="n">tb_check_return_val</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span>
        <span class="n">tb_check_return_val</span><span class="p">(</span><span class="n">size</span><span class="p">,</span> <span class="mi">0</span><span class="p">);</span>

        <span class="c1">// 依次从队列头部读取每块buffer的数据，直到读满为止
</span>        <span class="n">tb_long_t</span> <span class="n">read</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
        <span class="k">while</span> <span class="p">(</span><span class="n">read</span> <span class="o">&lt;</span> <span class="n">size</span> <span class="o">&amp;&amp;</span> <span class="n">tb_queue_size</span><span class="p">(</span><span class="n">rstream</span><span class="o">-&gt;</span><span class="n">buffers</span><span class="p">))</span>
        <span class="p">{</span>
            <span class="c1">// get buffer
</span>            <span class="n">tb_real_buffer_ref_t</span> <span class="n">buffer</span> <span class="o">=</span> <span class="n">tb_queue_get</span><span class="p">(</span><span class="n">rstream</span><span class="o">-&gt;</span><span class="n">buffers</span><span class="p">);</span>
            <span class="n">tb_assert_and_check_break</span><span class="p">(</span><span class="n">buffer</span> <span class="o">&amp;&amp;</span> <span class="n">buffer</span><span class="o">-&gt;</span><span class="n">data</span> <span class="o">&amp;&amp;</span> <span class="n">buffer</span><span class="o">-&gt;</span><span class="n">size</span><span class="p">);</span>

            <span class="c1">// read data
</span>            <span class="k">if</span> <span class="p">(</span><span class="n">buffer</span><span class="o">-&gt;</span><span class="n">read</span> <span class="o">&lt;</span> <span class="n">buffer</span><span class="o">-&gt;</span><span class="n">size</span><span class="p">)</span>
            <span class="p">{</span>
                <span class="c1">// calculate the need size
</span>                <span class="n">tb_size_t</span> <span class="n">need</span> <span class="o">=</span> <span class="n">tb_min</span><span class="p">(</span><span class="n">size</span> <span class="o">-</span> <span class="n">read</span><span class="p">,</span> <span class="n">buffer</span><span class="o">-&gt;</span><span class="n">size</span> <span class="o">-</span> <span class="n">buffer</span><span class="o">-&gt;</span><span class="n">read</span><span class="p">);</span>

                <span class="c1">// copy data
</span>                <span class="n">tb_memcpy</span><span class="p">(</span><span class="n">data</span> <span class="o">+</span> <span class="n">read</span><span class="p">,</span> <span class="n">buffer</span><span class="o">-&gt;</span><span class="n">data</span> <span class="o">+</span> <span class="n">buffer</span><span class="o">-&gt;</span><span class="n">read</span><span class="p">,</span> <span class="n">need</span><span class="p">);</span>

                <span class="c1">// update the read size for buffer
</span>                <span class="n">buffer</span><span class="o">-&gt;</span><span class="n">read</span> <span class="o">+=</span> <span class="n">need</span><span class="p">;</span>

                <span class="c1">// update the total read size
</span>                <span class="n">read</span> <span class="o">+=</span> <span class="n">need</span><span class="p">;</span>
            <span class="p">}</span>

            <span class="c1">// 将读空的buffer释放掉
</span>            <span class="k">if</span> <span class="p">(</span><span class="n">buffer</span><span class="o">-&gt;</span><span class="n">read</span> <span class="o">==</span> <span class="n">buffer</span><span class="o">-&gt;</span><span class="n">size</span><span class="p">)</span>
                <span class="n">tb_queue_pop</span><span class="p">(</span><span class="n">rstream</span><span class="o">-&gt;</span><span class="n">buffers</span><span class="p">);</span>
        <span class="p">}</span>

        <span class="c1">// ok?
</span>        <span class="k">return</span> <span class="n">read</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="c1">// 实现wait回调接口，用于等待数据，tb_stream_wait/tb_stream_bread等阻塞读取接口会用到
</span>    <span class="k">static</span> <span class="n">tb_long_t</span> <span class="nf">tb_stream_real_wait</span><span class="p">(</span><span class="n">tb_stream_ref_t</span> <span class="n">stream</span><span class="p">,</span> <span class="n">tb_size_t</span> <span class="n">wait</span><span class="p">,</span> <span class="n">tb_long_t</span> <span class="n">timeout</span><span class="p">)</span>
    <span class="p">{</span>
        <span class="c1">// check
</span>        <span class="n">tb_stream_real_ref_t</span> <span class="n">rstream</span> <span class="o">=</span> <span class="p">(</span><span class="n">tb_stream_real_ref_t</span><span class="p">)</span><span class="n">stream</span><span class="p">;</span>
        <span class="n">tb_assert_and_check_return_val</span><span class="p">(</span><span class="n">rstream</span> <span class="o">&amp;&amp;</span> <span class="n">rstream</span><span class="o">-&gt;</span><span class="n">buffers</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">);</span>

        <span class="c1">// 当前是否有数据可读？
</span>        <span class="k">return</span> <span class="n">tb_queue_size</span><span class="p">(</span><span class="n">rstream</span><span class="o">-&gt;</span><span class="n">buffers</span><span class="p">)</span><span class="o">?</span> <span class="n">TB_STREAM_WAIT_READ</span> <span class="o">:</span> <span class="n">TB_STREAM_WAIT_NONE</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="c1">// 实现ctrl回调接口，用于设置和获取一些状态，扩展一些自定义的接口，tb_stream_ctrl接口会用到
</span>    <span class="k">static</span> <span class="n">tb_bool_t</span> <span class="nf">tb_stream_real_ctrl</span><span class="p">(</span><span class="n">tb_stream_ref_t</span> <span class="n">stream</span><span class="p">,</span> <span class="n">tb_size_t</span> <span class="n">ctrl</span><span class="p">,</span> <span class="n">tb_va_list_t</span> <span class="n">args</span><span class="p">)</span>
    <span class="p">{</span>
        <span class="c1">// check
</span>        <span class="n">tb_stream_real_ref_t</span> <span class="n">rstream</span> <span class="o">=</span> <span class="p">(</span><span class="n">tb_stream_real_ref_t</span><span class="p">)</span><span class="n">stream</span><span class="p">;</span>
        <span class="n">tb_assert_and_check_return_val</span><span class="p">(</span><span class="n">rstream</span><span class="p">,</span> <span class="n">tb_false</span><span class="p">);</span>

        <span class="c1">// ctrl
</span>        <span class="k">switch</span> <span class="p">(</span><span class="n">ctrl</span><span class="p">)</span>
        <span class="p">{</span>
        <span class="k">case</span> <span class="n">TB_STREAM_CTRL_GET_SIZE</span><span class="p">:</span>
            <span class="p">{</span>
                <span class="c1">// the psize
</span>                <span class="n">tb_hong_t</span><span class="o">*</span> <span class="n">psize</span> <span class="o">=</span> <span class="p">(</span><span class="n">tb_hong_t</span><span class="o">*</span><span class="p">)</span><span class="n">tb_va_arg</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="n">tb_hong_t</span><span class="o">*</span><span class="p">);</span>
                <span class="n">tb_assert_and_check_break</span><span class="p">(</span><span class="n">psize</span><span class="p">);</span>

                <span class="c1">// 获取数据流大小，tb_stream_size有用到
</span>                <span class="o">*</span><span class="n">psize</span> <span class="o">=</span> <span class="n">rstream</span><span class="o">-&gt;</span><span class="n">size</span><span class="p">;</span>

                <span class="c1">// ok
</span>                <span class="k">return</span> <span class="n">tb_true</span><span class="p">;</span>
            <span class="p">}</span>   
            <span class="c1">// 在另外一端通过tb_stream_ctrl来不断的送入数据块到stream
</span>        <span class="k">case</span> <span class="n">TB_STREAM_CTRL_REAL_PUSH</span><span class="p">:</span>
            <span class="p">{</span>
                <span class="c1">// check
</span>                <span class="n">tb_assert_and_check_break</span><span class="p">(</span><span class="n">rstream</span><span class="o">-&gt;</span><span class="n">buffers</span><span class="p">);</span>

                <span class="c1">// the data and size
</span>                <span class="n">tb_byte_t</span> <span class="k">const</span><span class="o">*</span>    <span class="n">data</span> <span class="o">=</span> <span class="p">(</span><span class="n">tb_byte_t</span> <span class="k">const</span><span class="o">*</span><span class="p">)</span><span class="n">tb_va_arg</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="n">tb_byte_t</span> <span class="k">const</span><span class="o">*</span><span class="p">);</span>
                <span class="n">tb_size_t</span>           <span class="n">size</span> <span class="o">=</span> <span class="p">(</span><span class="n">tb_size_t</span><span class="p">)</span><span class="n">tb_va_arg</span><span class="p">(</span><span class="n">args</span><span class="p">,</span> <span class="n">tb_size_t</span><span class="p">);</span>
                <span class="n">tb_assert_and_check_break</span><span class="p">(</span><span class="n">data</span> <span class="o">&amp;&amp;</span> <span class="n">size</span><span class="p">);</span>

                <span class="c1">// 压入一个数据块
</span>                <span class="n">tb_real_buffer_t</span> <span class="n">buffer</span><span class="p">;</span>
                <span class="n">buffer</span><span class="p">.</span><span class="n">data</span> <span class="o">=</span> <span class="n">tb_memdup</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">size</span><span class="p">);</span>
                <span class="n">buffer</span><span class="p">.</span><span class="n">size</span> <span class="o">=</span> <span class="n">size</span><span class="p">;</span>
                <span class="n">buffer</span><span class="p">.</span><span class="n">read</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
                <span class="n">tb_queue_put</span><span class="p">(</span><span class="n">rstream</span><span class="o">-&gt;</span><span class="n">buffers</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">buffer</span><span class="p">);</span>

                <span class="c1">// 更新总的数据大小
</span>                <span class="n">rstream</span><span class="o">-&gt;</span><span class="n">size</span> <span class="o">+=</span> <span class="n">size</span><span class="p">;</span>

                <span class="c1">// ok
</span>                <span class="k">return</span> <span class="n">tb_true</span><span class="p">;</span>
            <span class="p">}</span>
        <span class="nl">default:</span>
            <span class="k">break</span><span class="p">;</span>
        <span class="p">}</span>

        <span class="c1">// failed
</span>        <span class="k">return</span> <span class="n">tb_false</span><span class="p">;</span>
    <span class="p">}</span>
</code></pre>
</div>

<p>通过上面四步， 基本上一个自定义流就实现好了，上面说的<code class="highlighter-rouge">tb_real_buffer_exit</code>主要用于queue维护的buffer的自动释放
详细说明和使用见容器章节，下面附属相关实现：</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code>    <span class="k">static</span> <span class="n">tb_void_t</span> <span class="nf">tb_real_buffer_exit</span><span class="p">(</span><span class="n">tb_element_ref_t</span> <span class="n">element</span><span class="p">,</span> <span class="n">tb_pointer_t</span> <span class="n">buff</span><span class="p">)</span>
    <span class="p">{</span>
        <span class="c1">// check
</span>        <span class="n">tb_real_buffer_ref_t</span> <span class="n">buffer</span> <span class="o">=</span> <span class="p">(</span><span class="n">tb_real_buffer_ref_t</span><span class="p">)</span><span class="n">buff</span><span class="p">;</span>
        <span class="n">tb_assert_and_check_return</span><span class="p">(</span><span class="n">buffer</span><span class="p">);</span>

        <span class="c1">// exit it
</span>        <span class="k">if</span> <span class="p">(</span><span class="n">buffer</span><span class="o">-&gt;</span><span class="n">data</span><span class="p">)</span> <span class="n">tb_free</span><span class="p">(</span><span class="n">buffer</span><span class="o">-&gt;</span><span class="n">data</span><span class="p">);</span>
        <span class="n">buffer</span><span class="o">-&gt;</span><span class="n">data</span> <span class="o">=</span> <span class="n">tb_null</span><span class="p">;</span>
        <span class="n">buffer</span><span class="o">-&gt;</span><span class="n">size</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
        <span class="n">buffer</span><span class="o">-&gt;</span><span class="n">read</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
    <span class="p">}</span>
</code></pre>
</div>

<p>最后，贴下咱们这个自定义stream使用：</p>

<p>接收端</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code>    <span class="c1">// init stream
</span>    <span class="n">tb_stream_ref_t</span> <span class="n">stream</span> <span class="o">=</span> <span class="n">tb_stream_init_real</span><span class="p">();</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">stream</span><span class="p">)</span>
    <span class="p">{</span>
        <span class="c1">// open stream
</span>        <span class="k">if</span> <span class="p">(</span><span class="n">tb_stream_open</span><span class="p">(</span><span class="n">stream</span><span class="p">))</span>
        <span class="p">{</span>
            <span class="c1">// read line
</span>            <span class="n">tb_long_t</span> <span class="n">size</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
            <span class="n">tb_char_t</span> <span class="n">line</span><span class="p">[</span><span class="n">TB_STREAM_BLOCK_MAXN</span><span class="p">];</span>
            <span class="k">while</span> <span class="p">((</span><span class="n">size</span> <span class="o">=</span> <span class="n">tb_stream_bread_line</span><span class="p">(</span><span class="n">stream</span><span class="p">,</span> <span class="n">line</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">line</span><span class="p">)))</span> <span class="o">&gt;=</span> <span class="mi">0</span><span class="p">)</span>
            <span class="p">{</span>
                <span class="c1">// trace
</span>                <span class="n">tb_trace_i</span><span class="p">(</span><span class="s">"line: %s"</span><span class="p">,</span> <span class="n">line</span><span class="p">);</span>
            <span class="p">}</span>
        <span class="p">}</span>

        <span class="c1">// exit stream
</span>        <span class="n">tb_stream_exit</span><span class="p">(</span><span class="n">stream</span><span class="p">);</span>
    <span class="p">}</span>
</code></pre>
</div>

<p>基本上没什么变化，就是换了下stream的初始化创建接口</p>

<p>输入端</p>

<div class="language-c highlighter-rouge"><pre class="highlight"><code>    <span class="c1">// 将数据不停的送入stream中
</span>    <span class="k">while</span> <span class="p">(</span><span class="mi">1</span><span class="p">)</span>
    <span class="p">{</span>
        <span class="c1">// fill data
</span>        <span class="n">tb_byte_t</span> <span class="n">data</span><span class="p">[</span><span class="mi">8192</span><span class="p">];</span>
        <span class="n">tb_memset</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="mh">0xff</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">data</span><span class="p">));</span>

        <span class="c1">// push data
</span>        <span class="n">tb_stream_ctrl</span><span class="p">(</span><span class="n">stream</span><span class="p">,</span> <span class="n">TB_STREAM_CTRL_REAL_PUSH</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">data</span><span class="p">));</span>
    <span class="p">}</span>
</code></pre>
</div>

<p>上面介绍的实现和使用方式，只是个例子，方便理解tbox中stream的机制，具体实现和使用还是需要根据自己的实际需求做调整。</p>

<p>更详细的使用和扩展，可参考源代码来了解。。</p>


                </div>
                <div class="read-all">
 
                    
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    

                    <a href="/cn/2016/03/17/stream-custom/"><i class="fa fa-newspaper-o"></i>阅读全文</a>
                </div>
                <hr />
              </li>
            
              <li>
                <h2>
                  <a class="post-link" href="/cn/2016/02/25/update-v1.5.2/">tbox v1.5.2 更新!</a>
                </h2>
                <div class="label">
                    <div class="label-card">
                        <i class="fa fa-calendar"></i>2016-02-25
                    </div>
                    <div class="label-card">
                        
                    </div>
                    <div class="label-card">
                        
                    </div>

                    <div class="label-card">
                    


<!-- <span class="point">•</span> -->
<span class="categories">
  <i class="fa fa-th-list"></i>
  
    
        <a href="/category/#tbox" title="Category: tbox" rel="category">tbox</a>
    
  

  <!-- <span class="point">•</span> -->
</span>


                    </div>

                    <div class="label-card">
                    
<!-- <span class="point">•</span> -->
<span class="pageTag">
  <i class="fa fa-tags"></i>
  
    
        <a href="/cn/tag/#tbox" title="Tag: tbox" rel="tag">tbox</a>&nbsp;
    
        <a href="/cn/tag/#版本更新" title="Tag: 版本更新" rel="tag">版本更新</a>&nbsp;
    
        <a href="/cn/tag/#进程控制" title="Tag: 进程控制" rel="tag">进程控制</a>&nbsp;
    
        <a href="/cn/tag/#编译" title="Tag: 编译" rel="tag">编译</a>
    
  

</span>

                    </div>
                </div>
                <div class="excerpt">
                    <h3 id="新特性">新特性</h3>

<ul>
  <li>增加smallest参数配置选项，实现一键配置最小化编译，禁用所有扩展模块和依赖库</li>
  <li>增加进程创建和控制接口</li>
</ul>

<h3 id="改进">改进</h3>

<ul>
  <li>增强环境变量设置接口</li>
  <li>修改xmake.lua支持最新版xmake v2.x, 简化编译配置</li>
</ul>

<h3 id="bugs修复">Bugs修复</h3>

<ul>
  <li>修复ltimer定时器不准问题</li>
  <li>修复asio部分内存泄露问题</li>
  <li>修复asio/httpd在linux下keepalive模式，响应很慢问题</li>
  <li>修复windows下路径处理的一些bug</li>
</ul>


                </div>
                <div class="read-all">
 
                    
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                                
                                <a href="/2016/02/25/update-v1.5.2/"><i class="fa fa-language"></i>Read English</a>
                                
                                
                                
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    

                    <a href="/cn/2016/02/25/update-v1.5.2/"><i class="fa fa-newspaper-o"></i>阅读全文</a>
                </div>
                <hr />
              </li>
            
              <li>
                <h2>
                  <a class="post-link" href="/cn/2016/02/05/update-v1.5.1/">tbox v1.5.1 更新!</a>
                </h2>
                <div class="label">
                    <div class="label-card">
                        <i class="fa fa-calendar"></i>2016-02-05
                    </div>
                    <div class="label-card">
                        
                    </div>
                    <div class="label-card">
                        
                    </div>

                    <div class="label-card">
                    


<!-- <span class="point">•</span> -->
<span class="categories">
  <i class="fa fa-th-list"></i>
  
    
        <a href="/category/#tbox" title="Category: tbox" rel="category">tbox</a>
    
  

  <!-- <span class="point">•</span> -->
</span>


                    </div>

                    <div class="label-card">
                    
<!-- <span class="point">•</span> -->
<span class="pageTag">
  <i class="fa fa-tags"></i>
  
    
        <a href="/cn/tag/#tbox" title="Tag: tbox" rel="tag">tbox</a>&nbsp;
    
        <a href="/cn/tag/#版本更新" title="Tag: 版本更新" rel="tag">版本更新</a>
    
  

</span>

                    </div>
                </div>
                <div class="excerpt">
                    <h3 id="新特性">新特性</h3>

<ul>
  <li>自动检测所有系统libc接口，优先使用系统版本</li>
  <li>支持自定义内存分配器，并且能够在debug模式下，获取每次分配的代码位置信息，用于自定义追踪</li>
  <li>增加轻量级<code class="highlighter-rouge">static_pool</code>来维护整块buffer的内存分配，适合局部管理部分内存，pool虽然也能维护，但是底层基于<code class="highlighter-rouge">large_pool</code>，比较重量级，适合全局管理内存</li>
  <li>增加stream快速读取全部数据到string的接口</li>
  <li>增加adler32 hash算法</li>
  <li>增加<code class="highlighter-rouge">tb_memmem</code>接口</li>
  <li>采用pcre/pcre2/posix regex实现正则表达式库</li>
</ul>

<h3 id="改进">改进</h3>

<ul>
  <li>优化stream，支持对字符设备文件的读写</li>
  <li>修改<code class="highlighter-rouge">tb_init</code>接口，增加allocator自定义内存分配器参数，实现用户的侵入式内存管理</li>
  <li>重构内存管理，完全采用分配器allocator模式，可以灵活切换内存管理，支持原生系统内存、静态buffer内存、内存池等各种分配方式</li>
  <li>重定义assert，debug模式遇到assert直接abort执行</li>
</ul>

<h3 id="bugs修复">Bugs修复</h3>

<ul>
  <li>修复android下的一些bug</li>
  <li>修复stream的seek问题</li>
</ul>


                </div>
                <div class="read-all">
 
                    
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                                
                                <a href="/2016/02/05/update-v1.5.1/"><i class="fa fa-language"></i>Read English</a>
                                
                                
                                
                            
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    
                        
                        
                            
                        
                    
                        
                    

                    <a href="/cn/2016/02/05/update-v1.5.1/"><i class="fa fa-newspaper-o"></i>阅读全文</a>
                </div>
                <hr />
              </li>
            
        </ul>

        <!-- baidu ads -->
        

        <!-- Pagination links -->
        <div class="pagination">
          
            <a href="/cn/index.html" class="previous"><i class="fa fa-angle-double-left"></i></a>
            <a href="/cn/page35" class="previous"><i class="fa fa-angle-left"></i></a>
          
          <span class="page_number ">36/40</span>
          
            <a href="/cn/page37" class="next"><i class="fa fa-angle-right"></i></a>
            <a href="/cn/page40" class="next"><i class="fa fa-angle-double-right"></i></a>
          
        </div>
    </div>
    <!-- <button class="anchor"><i class="fa fa-anchor"></i></button> -->
    <div class="right">
        <div class="wrap">

            <!-- codefund ads -->
            

            <div class="side">
                <div>
                    <i class="fa fa-pencil-square-o" aria-hidden="true"></i>
                    最近文章
                </div>
                <ul class="content-ul" recent="">
                    
                    
                    
                        
                    
                    
                    
                        
                            <li><a href="/cn/2021/12/17/xmake-update-v2.6.2/">xmake v2.6.2 发布，新增 Linux 内核驱动模块构建支持</a></li>
                            
                        
                    
                    
                    
                        
                    
                    
                    
                        
                            <li><a href="/cn/2021/12/03/xmake-update-v2.6.1/">xmake v2.6.1 发布，使用 Lua5.4 运行时，Rust 和 C++ 混合编译支持</a></li>
                            
                        
                    
                    
                    
                        
                    
                    
                    
                        
                            <li><a href="/cn/2021/10/30/xmake-update-v2.5.9/">xmake v2.5.9 发布，改进 C++20 模块，并支持 Nim, Keil MDK 和 Unity Build</a></li>
                            
                        
                    
                    
                    
                        
                    
                    
                    
                        
                            <li><a href="/cn/2021/10/08/xmake-update-v2.5.8/">xmake v2.5.8 发布，新增 Pascal/Swig 程序和 Lua53 运行时支持</a></li>
                            
                        
                    
                    
                    
                        
                    
                    
                    
                        
                            <li><a href="/cn/2021/08/29/xmake-update-v2.5.7/">xmake v2.5.7 发布，包依赖锁定和 Vala/Metal 语言编译支持</a></li>
                            
                        
                    
                    
                    
                        
                    
                    
                    
                        
                            <li><a href="/cn/2021/07/26/xmake-update-v2.5.6/">xmake v2.5.6 发布，改进预编译二进制镜像包兼容性</a></li>
                            
                        
                    
                    
                    
                        
                    
                    
                    
                        
                            <li><a href="/cn/2021/06/30/xmake-update-v2.5.5/">xmake v2.5.5 发布，支持下载集成二进制镜像包</a></li>
                            
                        
                    
                    
                    
                        
                    
                    
                    
                        
                            <li><a href="/cn/2021/05/15/xmake-update-v2.5.4/">xmake v2.5.4 发布，支持 apt/portage 包管理器，改进 xrepo shell 环境</a></li>
                            
                        
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                    
                </ul>
            </div>

            <!-- baidu ads -->
            

            <!-- xmake courses -->
            <br />
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    xmake 入门课程
                </div>
                <a href="https://xmake.io/#/zh-cn/about/course" target="_blank">
                <img src="/static/img/xmake-course.png" alt="course" width="256" height="193" />
                </a>
            </div> 

            <!-- wechat public -->
            <br />
            <div class="side">
                <div>
                    <i class="fa fa-external-link"></i>
                    微信公众号
                </div>
                <img src="/static/img/weixin_public.jpg" alt="wechat" width="256" height="284" />
            </div> 

            <!-- 其他div框放到这里 -->
            <br />
            <div class="side">
                <div>
                    <i class="fa fa-tags"></i>
                    标记
                </div>
                <div class="tags-cloud">
                    
                    
                    
                    

                    

                    
                     
                     
                     
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#文档" style="font-size: 9pt; color: #999;">文档</a>
                    
                    
                    
                     
                    
                     
                     
                     
                    
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#插件" style="font-size: 9.5pt; color: #888;">插件</a>
                    
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#tboox" style="font-size: 9.5pt; color: #999;">tboox</a>
                    
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#站点" style="font-size: 9pt; color: #999;">站点</a>
                    
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                    
                     
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#算法" style="font-size: 9pt; color: #999;">算法</a>
                    
                    
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#容器" style="font-size: 9pt; color: #999;">容器</a>
                    
                    
                    
                     
                    
                     
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#内存池" style="font-size: 9pt; color: #999;">内存池</a>
                    
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#跨平台" style="font-size: 9pt; color: #999;">跨平台</a>
                    
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#异常捕获" style="font-size: 9pt; color: #999;">异常捕获</a>
                    
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#windows" style="font-size: 9.5pt; color: #999;">windows</a>
                    
                    
                    
                     
                     
                     
                    
                    
                     
                    
                     
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#编译" style="font-size: 9.5pt; color: #999;">编译</a>
                    
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#配置" style="font-size: 9pt; color: #999;">配置</a>
                    
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#stream" style="font-size: 9pt; color: #999;">stream</a>
                    
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#流" style="font-size: 9pt; color: #999;">流</a>
                    
                    
                    
                     
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#静态库" style="font-size: 9pt; color: #999;">静态库</a>
                    
                    
                    
                     
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#版本更新" style="font-size: 10pt; color: #888;">版本更新</a>
                    
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#类库" style="font-size: 9pt; color: #999;">类库</a>
                    
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#自定义脚本" style="font-size: 9pt; color: #999;">自定义脚本</a>
                    
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#安装" style="font-size: 9pt; color: #999;">安装</a>
                    
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#打包" style="font-size: 9pt; color: #999;">打包</a>
                    
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#android" style="font-size: 9.5pt; color: #999;">android</a>
                    
                    
                    
                     
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#doxygen" style="font-size: 9pt; color: #999;">doxygen</a>
                    
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#宏脚本" style="font-size: 9pt; color: #999;">宏脚本</a>
                    
                    
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#xmake.lua" style="font-size: 9pt; color: #999;">xmake.lua</a>
                    
                    
                    
                     
                    
                     
                     
                     
                    
                    
                     
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#project" style="font-size: 9pt; color: #999;">project</a>
                    
                    
                    
                     
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#交叉编译" style="font-size: 9pt; color: #999;">交叉编译</a>
                    
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#build" style="font-size: 9pt; color: #999;">build</a>
                    
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#调试" style="font-size: 9pt; color: #999;">调试</a>
                    
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#运行" style="font-size: 9pt; color: #999;">运行</a>
                    
                    
                    
                     
                    
                     
                     
                     
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#协程" style="font-size: 9.5pt; color: #999;">协程</a>
                    
                    
                    
                     
                    
                     
                     
                     
                    
                    
                     
                    
                     
                     
                     
                    
                    
                     
                    
                     
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#调试符号" style="font-size: 9pt; color: #999;">调试符号</a>
                    
                    
                    
                     
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#自动检测" style="font-size: 9pt; color: #999;">自动检测</a>
                    
                    
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                    
                    
                     
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#工程描述" style="font-size: 9pt; color: #999;">工程描述</a>
                    
                    
                    
                     
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#符号文件" style="font-size: 9pt; color: #999;">符号文件</a>
                    
                    
                    
                     
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#ios" style="font-size: 9pt; color: #999;">ios</a>
                    
                    
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                    
                    
                     
                    
                     
                    
                     
                     
                     
                    
                    
                     
                    
                     
                    
                     
                     
                     
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#逆向分析" style="font-size: 9pt; color: #999;">逆向分析</a>
                    
                    
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#手写数字识别" style="font-size: 9pt; color: #999;">手写数字识别</a>
                    
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#神经网络" style="font-size: 9pt; color: #999;">神经网络</a>
                    
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#人工智能" style="font-size: 9pt; color: #999;">人工智能</a>
                    
                    
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#图像处理" style="font-size: 9pt; color: #999;">图像处理</a>
                    
                    
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#定时器" style="font-size: 9pt; color: #999;">定时器</a>
                    
                    
                    
                     
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#时间轮算法" style="font-size: 9pt; color: #999;">时间轮算法</a>
                    
                    
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                    
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                    
                    
                     
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#context" style="font-size: 9pt; color: #999;">context</a>
                    
                    
                    
                     
                    
                     
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#boost" style="font-size: 9pt; color: #999;">boost</a>
                    
                    
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#服务器" style="font-size: 9pt; color: #999;">服务器</a>
                    
                    
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                    
                    
                     
                    
                     
                     
                     
                    
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#版本" style="font-size: 9pt; color: #999;">版本</a>
                    
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#包查找" style="font-size: 9pt; color: #999;">包查找</a>
                    
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#编译器特性检测" style="font-size: 9pt; color: #999;">编译器特性检测</a>
                    
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#预编译头文件" style="font-size: 9pt; color: #999;">预编译头文件</a>
                    
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#扩展模块" style="font-size: 9pt; color: #999;">扩展模块</a>
                    
                    
                    
                     
                    
                     
                     
                     
                    
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#稳定性修复" style="font-size: 9pt; color: #999;">稳定性修复</a>
                    
                    
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                    
                    
                     
                    
                     
                     
                     
                    
                    
                     
                    
                     
                    
                     
                     
                     
                    
                    
                     
                    
                     
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#Qt" style="font-size: 9pt; color: #999;">Qt</a>
                    
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                    
                     
                     
                     
                    
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#IOCP" style="font-size: 9pt; color: #999;">IOCP</a>
                    
                    
                    
                     
                    
                     
                     
                     
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#远程包管理" style="font-size: 9pt; color: #999;">远程包管理</a>
                    
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#包依赖" style="font-size: 9pt; color: #999;">包依赖</a>
                    
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#自动构建" style="font-size: 9pt; color: #999;">自动构建</a>
                    
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                    
                    
                     
                    
                     
                    
                     
                     
                     
                    
                    
                     
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#子工程" style="font-size: 9pt; color: #999;">子工程</a>
                    
                    
                    
                     
                     
                     
                      
                      
                      
                      
                      
                      <a href="/cn/tag/#子模块" style="font-size: 9pt; color: #999;">子模块</a>
                    
                    
                    
                     
                    
                     
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                    
                     
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                    
                     
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                    
                     
                    
                     
                    
                     
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                     
                     
                     
                    
                    
                </div>
            </div>

            

            <!-- baidu ads -->
            

        </div>
    </div>

    <!-- baidu ads -->
    
</div>



    <footer class="site-footer">
    <div class="wrapper">
        <p class="description">
             Copyright (c) 2016-2020 tboox.org 
        </p>
        <p class="contact">
            
            <a href="https://github.com/waruqi" title="GitHub"><i class="fa fa-github" aria-hidden="true"></i></a> 
             
            
            <a href="mailto:waruqi@gmail.com" title="email"><i class="fa fa-envelope-o" aria-hidden="true"></i></a> 
            
            
            <a href="https://twitter.com/waruqi" title="Twitter"><i class="fa fa-twitter" aria-hidden="true"></i></a> 
            
            <a href="/feed.xml" title="feed"><i class="fa fa-feed" aria-hidden="true"></i></a> 
        </p>
        <p class="power">
            <span>
                Site powered by <a href="https://jekyllrb.com/">Jekyll</a> & <a href="https://github.com/Gaohaoyang">HyG</a> & <a href="https://pages.github.com/">Github Pages</a>.
            </span>
        </p>
    </div>
</footer>

    <div class="back-to-top">
    <a href="#top" class="scroll">
        <i class="fa fa-arrow-up" aria-hidden="true"></i>
    </a>
</div>

    <script src=" /js/main.js " charset="utf-8"></script>
    <script src=" /js/scroll.min.js " charset="utf-8"></script>
  </body>

</html>
